/**
 * Copyright 2018 asiainfo Inc.
 **/
package com.myz.rabbitmq.common.config;

import org.springframework.amqp.core.Queue;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * 队列配置  可以配置多个队列
 *
 * @author maoyz on 2018/8/28
 * @version: v1.0
 */
@Configuration
@AutoConfigureBefore({DirectExchangeConfig.class, FanoutExchangeConfig.class, TopicExchangeConfig.class})
public class QueueConfig {

    @Bean
    public Queue easyQueue() {
        return new Queue(RabbitMqConstant.QueueName.FIRST_QUEUE.getCode(), true, false, false);
    }

    @Bean
    public Queue firstQueue() {
        return new Queue(RabbitMqConstant.QueueName.FIRST_QUEUE.getCode(), true, false, false);
    }

    @Bean
    public Queue secondQueue() {
        return new Queue(RabbitMqConstant.QueueName.TOPIC_QUEUE1.getCode(), true, false, false);
    }

    /**
     * 配置 自动删除
     */
    @Bean
    public Queue thirdQueue() {
        Map<String, Object> arguments = new HashMap<>();
        arguments.put("x-message-ttl", 60000);
        return new Queue(RabbitMqConstant.QueueName.TOPIC_QUEUE2.getCode(), true, false, true, arguments);
    }
}
